package cn.xdf.Demo01;

import cn.xdf.dao.UserDao;
import cn.xdf.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "classpath:spring.xml")
public class demo02_方法命名查询 {

    @Autowired
    private UserDao userDao;

    @Test
    public void test01(){
        User user = userDao.findByUsername("小美");
        System.out.println(user);
    }

    @Test
    public void test02(){
        List<User> userList = userDao.findByUsernameLike("%o%");
        for(User user :userList){
            System.out.println(user);
        }

    }

    @Test
    public void test03(){
        List<User> userList = userDao.findByUsernameLikeOrderByBirthdayDesc("%o%");
        for(User user :userList){
            System.out.println(user);
        }

    }




}
